﻿/*****************************************介绍*****************************************
 * 作者：User
 * 创建时间：2025-09-25 19:49:31
 * 功能：单个下拉项
**************************************************************************************/

using System.Collections;
using UnityEngine;
using UnityEngine.UI;

namespace Game.UI.HallPanel
{
    public class DropdownItem : MonoBehaviour
    {
        private GameObject m_Lock;

        private void Awake()
        {
            m_Lock = transform.Find("Lock").gameObject;
        }

        private void OnEnable()
        {
            StartCoroutine(DelayLock());
        }

        private IEnumerator DelayLock()
        {
            yield return new WaitForSeconds(0.01f);
            var data = GameDataMgr.Instance.MapInfo[name.Split(": ")[1]];
            if (data == null) yield break;
            m_Lock.SetActive(!data.isUnlocked);
            transform.Find("Item Label").GetComponent<Text>().color = data.isUnlocked ? Color.white : new Color32(152, 198, 81, 255);
        }
    }
}